package com.fr.chart.axis;

import com.fr.base.FRFont;
import com.fr.base.XMLable;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.BaseXMLUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.base.equals.Equals;

public class TextAttr
  implements XMLable
{
  private static final long serialVersionUID = -4216006140409740068L;
  public static final String XML_TAG = "TextAttr";
  private FRFont frFont = null;
  private int direction = 1;
  private int rotation = 0;
  private int horizontalAlignment = 2;
  private int verticalAlignment = 0;
  private int alignText = 0;

  public TextAttr()
  {
  }

  public TextAttr(FRFont paramFRFont)
  {
    this.frFont = paramFRFont;
  }

  public FRFont getFRFont()
  {
    return this.frFont;
  }

  public void setFRFont(FRFont paramFRFont)
  {
    this.frFont = paramFRFont;
  }

  public void setDirection(int paramInt)
  {
    this.direction = paramInt;
  }

  public int getDirection()
  {
    return this.direction;
  }

  public int getRotation()
  {
    return this.rotation;
  }

  public void setRotation(int paramInt)
  {
    this.rotation = paramInt;
  }

  public void setHorizontalAlignment(int paramInt)
  {
    this.horizontalAlignment = paramInt;
  }

  public int getHorizontalAlignment()
  {
    return this.horizontalAlignment;
  }

  public void setVerticalAlignment(int paramInt)
  {
    this.verticalAlignment = paramInt;
  }

  public int getVerticalAlignment()
  {
    return this.verticalAlignment;
  }

  public void setAlignText(int paramInt)
  {
    this.alignText = paramInt;
  }

  public int getAlignText()
  {
    return this.alignText;
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof TextAttr))
      return false;
    TextAttr localTextAttr = (TextAttr)paramObject;
    if (localTextAttr.getAlignText() != getAlignText())
      return false;
    if (localTextAttr.getDirection() != getDirection())
      return false;
    if (localTextAttr.getHorizontalAlignment() != getHorizontalAlignment())
      return false;
    if (localTextAttr.getVerticalAlignment() != getVerticalAlignment())
      return false;
    if (localTextAttr.getRotation() != getRotation())
      return false;
    return (Equals.equals(localTextAttr.getFRFont(), getFRFont()));
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
      if ("FRFont".equals(paramXMLableReader.getTagName()))
      {
        this.frFont = BaseXMLUtils.readFRFont(paramXMLableReader);
      }
      else if (paramXMLableReader.getTagName().equals("Attr"))
      {
        String str;
        if ((str = paramXMLableReader.getAttr("direction")) != null)
          setDirection(Integer.parseInt(str));
        if ((str = paramXMLableReader.getAttr("rotation")) != null)
          setRotation(Integer.parseInt(str));
        if ((str = paramXMLableReader.getAttr("h_align")) != null)
          setHorizontalAlignment(Integer.parseInt(str));
        if ((str = paramXMLableReader.getAttr("v_align")) != null)
          setVerticalAlignment(Integer.parseInt(str));
        if ((str = paramXMLableReader.getAttr("alignText")) != null)
          setAlignText(Integer.parseInt(str));
      }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("TextAttr");
    paramXMLPrintWriter.startTAG("Attr");
    if (getDirection() != 1)
      paramXMLPrintWriter.attr("direction", getDirection());
    if (getRotation() != 0)
      paramXMLPrintWriter.attr("rotation", getRotation());
    if (getHorizontalAlignment() != 2)
      paramXMLPrintWriter.attr("h_align", getHorizontalAlignment());
    if (getVerticalAlignment() != 0)
      paramXMLPrintWriter.attr("v_align", getVerticalAlignment());
    paramXMLPrintWriter.attr("alignText", getAlignText());
    if (getFRFont() != null)
      BaseXMLUtils.writeFRFont(paramXMLPrintWriter, getFRFont());
    paramXMLPrintWriter.end();
    paramXMLPrintWriter.end();
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    return super.clone();
  }

  public JSONObject toJSONObject()
    throws JSONException
  {
    JSONObject localJSONObject = new JSONObject();
    if (this.frFont != null)
      localJSONObject.put("frFont", this.frFont.toJSONObject());
    localJSONObject.put("alignText", this.alignText);
    localJSONObject.put("direction", this.direction);
    localJSONObject.put("horizontalAlignment", this.horizontalAlignment);
    localJSONObject.put("rotation", this.rotation);
    localJSONObject.put("verticalAlignment", this.verticalAlignment);
    return localJSONObject;
  }
}